package org.forever.view
{
	import flash.events.MouseEvent;
	
	import mx.logging.ILogger;
	import mx.logging.Log;
	
	import spark.components.BorderContainer;

	/**折线用到的矩形点类*/
	public class BrokenLineRect extends BorderContainer
	{
		
		private static var _log:ILogger = Log.getLogger("org.forever.view.BrokenLineRect");
		private var _firstEdge:BrokenLineEdge;
		private var _secondEdge:BrokenLineEdge;
		
		private var _prevRect:BrokenLineRect;
		private var _nextRect:BrokenLineRect;
		private var _isSplit:Boolean = false;
		private var _rect_w:Number = 6; 
		private var _count:Number = 0;
		private var _direction:Number = 0;
		
		private  var _desc:String;
		
		
		public function BrokenLineRect()
		{
		}
		
		public function print():void{
			_log.debug("*******************("+_desc+")信息************************************");
			_log.debug("前驱矩形：" + (_prevRect!=null?_prevRect.desc:"没有前驱矩形"));
			_log.debug("后继矩形：" + (_nextRect!=null? _nextRect.desc:"没有后继矩形"));
			_log.debug("第一条关联边：" + (_firstEdge!=null? _firstEdge.desc:"没有第一条关联边"));
			_log.debug("第二条关联边：" + (_secondEdge!=null? _secondEdge.desc:"没有第二条关联边"));
			_log.debug("*********************************************************************");
		}
		
		public function refresh():void{
			updateFirstEdgePosition(); 
			updateSecondEdgePosition();
			updateNextRectPosition();
			updatePrevRectPosition();
		}
		
		/**更新第二条边的位置*/
		public function updateSecondEdgePosition():void{
			if(_secondEdge != null){
				_secondEdge.drawLine();
			}
		}
		
		/**更新后继矩形的位置*/
		public function updateNextRectPosition():void{
			if(_nextRect != null && _nextRect.nextRect != null){
				_nextRect.x = (x + _nextRect.nextRect.x)/2;
				_nextRect.y = (y + _nextRect.nextRect.y)/2;
			}
		}
		
		/**更新前驱矩形的位置*/
		public function updatePrevRectPosition():void{
			if(_prevRect != null && _prevRect.prevRect != null){
				_prevRect.x = (x + _prevRect.prevRect.x)/2;
				_prevRect.y = (y + _prevRect.prevRect.y)/2;
			}
		}
		
		/**更新第一条边的位置*/
		public function updateFirstEdgePosition():void{
			if(_firstEdge != null){
				_firstEdge.drawLine();
			}
		}
		
		
		public function updateFirstEdge():void{
		  if(_firstEdge != null ){
			  
		  }
		}
		
		/**矩形关联的第一条边(左边)*/
		public function get firstEdge():BrokenLineEdge
		{
			return _firstEdge;
		}

		/**
		 * @private
		 */
		public function set firstEdge(value:BrokenLineEdge):void
		{
			_firstEdge = value;
		}

		/**矩形关联的第二条边(右边)*/
		public function get secondEdge():BrokenLineEdge
		{
			return _secondEdge;
		}

		/**
		 * @private
		 */
		public function set secondEdge(value:BrokenLineEdge):void
		{
			_secondEdge = value;
		}

		/**前驱矩形节点*/
		public function get prevRect():BrokenLineRect
		{
			return _prevRect;
		}

		/**
		 * @private
		 */
		public function set prevRect(value:BrokenLineRect):void
		{
			_prevRect = value;
		}

		/**后继矩形节点*/
		public function get nextRect():BrokenLineRect
		{
			return _nextRect;
		}

		/**
		 * @private
		 */
		public function set nextRect(value:BrokenLineRect):void
		{
			_nextRect = value;
		}

		/**是否拆分过，即创建了该矩形与前驱(后继)矩形的中点矩形*/
		public function get isSplit():Boolean
		{
			return _isSplit;
		}

		/**
		 * @private
		 */
		public function set isSplit(value:Boolean):void
		{
			_isSplit = value;
		}

		public function get desc():String
		{
			return _desc;
		}

		public function set desc(value:String):void
		{
			_desc = value;
		}

		/**拖动方向,0未初始化，1正方向，-1反方向*/
		public function get direction():Number
		{
			return _direction;
		}

		/**
		 * @private
		 */
		public function set direction(value:Number):void
		{
			_direction = value;
		}


	}
}